package com.cn.lf.wx.dacs.bussiness.author.action;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.cn.lf.wx.dacs.bussiness.author.bean.ReturnEntity;
import com.cn.lf.wx.dacs.bussiness.author.bean.SearchData;
import com.cn.lf.wx.dacs.bussiness.author.bean.req.ChangeUserPass;
import com.cn.lf.wx.dacs.bussiness.author.bean.req.LoginUser;
import com.cn.lf.wx.dacs.bussiness.author.entity.AuthUser;
import com.cn.lf.wx.dacs.bussiness.author.serviceImpl.AuthUserServiceImpl;


@RestController

public class AuthUserApi {

	@Autowired
    private AuthUserServiceImpl authUserService;

    ////    登录
    @CrossOrigin
    @PostMapping("/admin/login")
    public ReturnEntity login(@RequestBody LoginUser loginUser) {
        return authUserService.login(loginUser);
    }

    //    检查 token
    @GetMapping("/admin/token")
    public ReturnEntity checkToken() {
        return authUserService.checkToken();
    }


    // @PreAuthorize("@permission.login()")
    @GetMapping("/admin/auth/users")
    public ReturnEntity users(SearchData searchData) {
        return authUserService.users(searchData);
    }

    // @PreAuthorize("@permission.login()")
    @PostMapping("/admin/auth/user")
    public ReturnEntity createUser(@RequestBody AuthUser user) {
        return this.authUserService.createUser(user);
    }

    //    修改 用户信息
    // @PreAuthorize("@permission.login()")
    @PutMapping("/admin/auth/user")
    public ReturnEntity changeUser(@RequestBody AuthUser user) {
        return this.authUserService.changeUser(user);
    }

    //    禁用 | 启用 用户
     // @PreAuthorize("@permission.login()")
    @PostMapping("/admin/auth/user/status")
    public ReturnEntity changeUserStatus(@RequestBody AuthUser user) {
        return this.authUserService.changeUserStatus(user);
    }

     // @PreAuthorize("@permission.login()")
    @PostMapping("/admin/auth/user/password")
    public ReturnEntity changeUserPass(@RequestBody ChangeUserPass changeUserPass) {
        return authUserService.changeUserPass(changeUserPass);
    }

}
